Using data provided by the Office of Spill Prevention and Response (OSPR) database, reported incidents of oil spills in California during the year 2008 was visualized. First, every 2008 oil spill location was mapped on an interactive map with CA county borders. The second part of the analysis includes a choropleth map was created to visualize which counties had the highest number of inland oil spill incidents in 2008.
Data Citation: Lampinen, Mark (2020). Oil Spill Incident Tracking [ds394]. California Department of Fish and Game, Office of Spill Prevention and Response. https://gis.data.ca.gov/datasets/CDFW::oil-spill-incident-tracking-ds394-1/about
# read in oil spill dataframe
oil_spill_df <- read_csv(here("data", "Oil_Spill_Incident_Tracking.csv")) %>%
janitor::clean_names()
# Read in CA county outlines
ca_counties_sf <- read_sf(here("data", "ca_counties", "CA_Counties_TIGER2016.shp")) %>% # a way to read in vector data to create a simple features object
janitor::clean_names() %>% # gets rid of capitals
select(county_name = name, land_area = aland)
# determine county sf crs
ca_counties_crs <- st_crs(ca_counties_sf)
# ca_counties_crs #3857
#convert oil spill df to sf
oil_spill_sf <- oil_spill_df %>%
drop_na(latitude, longitude) %>%
st_as_sf(coords = c("x", "y"), crs = ca_counties_crs)
tmap_mode("view")
tm_shape(ca_counties_sf) +
tm_borders() +
tm_shape(oil_spill_sf) +
tm_dots(col = "specificlo") +
tm_layout(legend.outside = TRUE) +
tm_layout(title = "California Oil Spill Events in 2008", title.size = 1.5) +
tm_minimap()
Figure 1. Reported oil spill incidents in California in 2008. The user can click on the point to obtain more information on each event.
# wrangle oil spill data
oil_spill_subset <- oil_spill_df %>%
filter(inlandmari == "Inland")
# spatially join county and oil spill data
ca_spill_sf<- ca_counties_sf %>%
st_join(oil_spill_sf)
spill_counts_sf <- ca_spill_sf %>%
filter(inlandmari == "Inland") %>%
group_by(county_name) %>%
summarize(n_spills = n())
## Plot the results
ggplot(data = spill_counts_sf ) +
geom_sf(aes(fill = n_spills),
color = "grey30",
size = 0.1) +
scale_fill_gradientn(colors = c("lightblue1", "darkslategray4", "darkslategrey")) +
labs(fill = "Number of Inland Oil Spills")
Figure 2. California oil spills that occurred inland in 2008 by county. Counties with darker blues depict a greater number of spills compared to the rest of the state.